package com.zhilun;

import org.apache.commons.collections4.CollectionUtils;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Collection;
import java.util.List;

public class ReadFileExample {
    public static void main(String[] args) {
        String filePath = "C:\\Users\\hcf\\IdeaProjects\\dache-test\\service-hi\\src\\main\\resources\\zhilun-sensor.txt"; // 文件路径
        String filePath2 = "C:\\Users\\hcf\\IdeaProjects\\dache-test\\service-hi\\src\\main\\resources\\dache-sensor.txt"; // 文件路径
        String filePath3 = "C:\\Users\\hcf\\IdeaProjects\\dache-test\\service-hi\\src\\main\\resources\\replace.txt"; // 文件路径

        try {
            // 读取文件内容并按换行符切分
            List<String> zhiLun = Files.readAllLines(Paths.get(filePath));
            List<String> daChe = Files.readAllLines(Paths.get(filePath2));
            List<String> sensorIdList = Files.readAllLines(Paths.get(filePath));

            for (String sensorId : sensorIdList) {
                String sql = "UPDATE device_bind_sensor_last SET `location` = 98 WHERE sensor_id = '" + sensorId + "';";
                // 输出每条SQL语句
                System.out.println(sql);
            }

            Collection<String> subtractList = CollectionUtils.subtract(zhiLun, daChe);
            Collection<String> subtractList2 = CollectionUtils.subtract(daChe, zhiLun);
            //知轮有 大车无
           // System.out.println(subtractList);
            //知轮无 大车有
          //  System.out.println(subtractList2);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
